import UICore from "../../../../Core/Res/UICore";
import AbstractUIWindow from "../../window/AbstractUIWindow";
import * as fgui from "fairygui-cc";

export class AlertWindow extends AbstractUIWindow {
    private titletxt: fgui.GTextField;
    private desc: fgui.GTextField;
    private callBack: Function;
    private cancel: fgui.GButton;
    private confirm: fgui.GButton;
    protected getResList(): Array<string> {
        return ["Common"];
    }
    protected onInit(): void {
        this._view = UICore.createObject("Common", "AlertWindow").asCom;
    }
    protected onShow(title: string, desc: string, okcallback: Function): void {
        this.titletxt.text = title;
        this.desc.text = desc;
        this.callBack = okcallback;
        this.cancel.onceClick(this.clickcancel, this);
        this.confirm.onceClick(this.clickconfirm, this);
    }
    private clickcancel(): void {
        this.close();
    }
    private clickconfirm(): void {
        this.callBack();
        this.close();
    }
}